'use strict';

console.log('content.js is running!');

// 插入 script，用于覆写xhr
let s = document.createElement('script');
s.src = chrome.runtime.getURL('script.js');
s.onload = function() { this.remove(); };
(document.head || document.documentElement).appendChild(s);

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
  console.log('changeFilterSwitch message received', request);
  if (request.action === "configSave") {
    localStorage.setItem('selectedSites', JSON.stringify(request.data.selectedSites));
    localStorage.setItem('excludeCmsFile', JSON.stringify(request.data.excludeCmsFile));
    sendResponse('configSaveSucc');
  }
});